-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude test environments from Sentry reporting #140
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for the change.
I see we use process.env.E2E
in some other places. Would it make sense to unify this to use one or another everywhere?
package.json
Outdated
"test": "NODE_ENV=test jest", | ||
"test:watch": "NODE_ENV=test jest --watch", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From reviewing documentation and testing locally, defining this explicitly is unnecessary as Jest sets NODE_ENV=test
if it is not set to something else.
Jest will set
process.env.NODE_ENV
to'test'
if it's not set to something else.
That said, I'm fine keeping this here to be explicit, if preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see we use process.env.E2E in some other places. Would it make sense to unify this to use one or another everywhere?
From reviewing documentation and testing locally, defining this explicitly is unnecessary as Jest sets NODE_ENV=test if it is not set to something else.
Good points, both. I think it makes sense to leverage the existing process.env.E2E
event for E2E tests -- I hadn't yet noted that we were already using it. I'll update both areas and check that the env is being set prior to running E2E builds, as noted in #140 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! From my testing, the latest changes appear to accomplish the desired outcome. Thank you for reducing the error logging noise.
Testing diff
diff --git a/e2e/e2e-helpers.ts b/e2e/e2e-helpers.ts
index feb764d..948e348 100644
--- a/e2e/e2e-helpers.ts
+++ b/e2e/e2e-helpers.ts
@@ -4,6 +4,7 @@ import { _electron as electron } from 'playwright';
export async function launchApp( testEnv: NodeJS.ProcessEnv = {} ) {
// find the latest build in the out directory
const latestBuild = findLatestBuild();
+ console.log( '>>>', { E2E: process.env.E2E, NODE_ENV: process.env.NODE_ENV } );
// parse the packaged Electron app and find paths and other info
const appInfo = parseElectronApp( latestBuild );
diff --git a/src/index.ts b/src/index.ts
index e9ff8b4..d64da96 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -6,6 +6,7 @@ import {
type IpcMainInvokeEvent,
globalShortcut,
Menu,
+ dialog,
} from 'electron';
import path from 'path';
import * as Sentry from '@sentry/electron/main';
@@ -26,6 +27,12 @@ import setupWPServerFiles from './setup-wp-server-files';
import { setupUpdates } from './updates';
import { stopAllServersOnQuit } from './site-server'; // eslint-disable-line import/order
+app.whenReady().then( () => {
+ dialog.showMessageBox( {
+ message: `E2E ${ process.env.E2E } / ENV ${ process.env.NODE_ENV }`,
+ } );
+} );
+
Sentry.init( {
dsn: 'https://97693275b2716fb95048c6d12f4318cf@o248881.ingest.sentry.io/4506612776501248',
debug: true,
Proposed Changes
Reduce Sentry noise by excluding test environments:
process.env.NODE_ENV !== 'test'
to Sentry init configNODE_ENV=test
Testing Instructions
Run testing commands like
npm run e2e
ornpm run test
to observe that Sentry events are not reported.Pre-merge Checklist